package com.leyou.item.client;

import com.leyou.common.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient("item-service")
public interface ItemClient {

    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> pageQuery(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "id", required = false) Long id,
            @RequestParam(value = "brandId", required = false) Long bid,
            @RequestParam(value = "categoryId", required = false) Long cid,
            @RequestParam(value = "saleable", required = false) Boolean saleable);

    /**
     * 根据spuId查询对应的sku的集合
     *
     * @param spuId
     * @return
     */
    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> querySkuBySpuId(@RequestParam("id") Long spuId);

    /**
     * 根据spuId以及是否可搜索查询规格参数集合信息
     *
     * @param id
     * @param searching
     * @return
     */
    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> queryParams(
            @RequestParam("id") Long id,
            @RequestParam(value = "searching", required = false) Boolean searching);


    /**
     * 根据品牌的id集合查询对应得品牌集合
     * @param ids
     * @return
     */
    @GetMapping("/brand/list")
     List<BrandDTO> queryBrandByIds(@RequestParam("ids") List<Long> ids);


    /**
     * 根据分类的id的集合查询对应的分类的集合
     * @param ids
     * @return
     */
    @GetMapping("/category/list")
     List<CategoryDTO> queryCategoryByIds(
            @RequestParam("ids") List<Long> ids);

    /**
     * 根据id查询spu的基本信息
     *
     * @param id
     * @return
     */
    @GetMapping("/goods/spu/{id}")
    SpuDTO querySpu(@PathVariable("id") Long id);

    /**
     * 根据spuId查询对应的额spuDetail
     *
     * @param spuId
     * @return
     */
    @GetMapping("/goods/spu/detail")
    SpuDetailDTO querySpuDetailById(@RequestParam("id") Long spuId);


    /**
     * 根据id查询对应的品牌信息
     *
     * @param id
     * @return
     */
    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id") Long id);

    /**
     * 根据分类id查询对应的规格参数组信息
     *
     * @param cid
     * @return
     */
    @GetMapping("/spec/groups/of/category")
    List<SpecGroupDTO> queryGroupByCategory(@RequestParam("id") Long cid);


}
